def prime_number(n):
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            return False
    return True


def finding_a_prime_number(n):
    if prime_number(n):
        return n
    maximum = n + 1
    minimum = n - 1
    while True:
        if prime_number(minimum):
            return minimum
        elif prime_number(maximum):
            return maximum
        minimum -= 1
        maximum += 1


d = {'zero': '0', 'one': '1', 'two': '2', 'three': '3',
     'four': '4', 'five': '5', 'six': '6', 'seven': '7',
     'eight': '8', 'nine': '9'}

string = input().split()
answer = str()
keys = d.keys()
fl = True
for el in string:
    if el in keys and len(answer) != 3:
        answer += d[el]
        if len(answer) == 3:
            break
    else:
        fl = False
        print('Wrong answer')
        break

if fl:
    n = int(answer)
    if prime_number(n):
        print(n)
    else:
        print(finding_a_prime_number(n))